package controller;

import entity.Supplier;
import entity.Warehouse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import service.WarehouseService;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/war")
public class WarehouseCon {
    @Resource(name="warehouseService")
    private WarehouseService warehouseService;

    @RequestMapping("/query")
    @ResponseBody
    public List<Warehouse> list(){
        return warehouseService.list();
    }

    @RequestMapping("/Qtiaozhuan")
    public String tiaozhuan(Model model) {
        return "WEB-INF/jsp/xitongshezhi/cangkushezhi";
    }
    @RequestMapping("/Qtianjia")
    @ResponseBody
    public List<Warehouse> add2(Warehouse warehouse){
        Warehouse warehouse1=new Warehouse();


        int s=warehouseService.Qadd(warehouse);

        return warehouseService.list();

    }
    @RequestMapping("/Qxiugai")
    @ResponseBody
    public List<Warehouse> Qupd(Warehouse warehouse){
        Supplier supplier1=new Supplier();
        int s=warehouseService.Qupd(warehouse);

        return warehouseService.list();
    }
    @RequestMapping("/Qdel")
    @ResponseBody
    public List<Warehouse> Qdel(Warehouse warehouse){
        Supplier supplier1=new Supplier();
        int s=warehouseService.Qdel(warehouse);
        return warehouseService.list();

    }

    @RequestMapping("/Qlist")
    @ResponseBody
    public List<Warehouse> Qlist(String name){
        Warehouse warehouse=new Warehouse();
        warehouse.setName(name);

        Map<String, Object> mapResult = new HashMap<String, Object>();

        mapResult.put("name",name);
        List<Warehouse> warehouses=warehouseService.Qlist(mapResult);
        return warehouses;

    }





}
